package com.zhbr.mvp.presenter;

import com.zhbr.common.rx.BaseSubscriber;
import com.zhbr.entity.MPageInfo;
import com.zhbr.entity.TGdfwPqgd;
import com.zhbr.mvp.base.presenter.BasePresenter;
import com.zhbr.mvp.contract.PageConstract;
import com.zhbr.mvp.model.PageModel;
import com.zhbr.mvp.ui.fragment.PageFragment1;

import java.util.HashMap;

public class PagePresenter extends BasePresenter<PageConstract.View,PageConstract.Model> implements PageConstract.Presenter {
    @Override
    protected PageConstract.Model createModule() {
        return new PageModel();
    }

    @Override
    public void onGetData(int pageNum,int pageSize) {
        mModel.onGetData(pageNum,pageSize, new BaseSubscriber<MPageInfo<TGdfwPqgd>>() {
            @Override
            public void onSuccess(MPageInfo<TGdfwPqgd> data) {
                if (isViewAttach()){
                    getView().onGetDataSuccess(data);
                }
            }

            @Override
            public void onFailed(Throwable ex, String code, String msg) {
                getView().onGetDataFail(ex, code, msg);
            }

            @Override
            public void onError() {
                onNetError();
            }
        });
    }
}
